<?php
/* @var $this BlockController */
/* @var $model Block */

$this->breadcrumbs=array(
        'Háztömbök',
);


$columns = array(
        'name',
        'code',
);

// user column
if(checkAccess('admin')){
    $columns[] = array(
            'name'=>'user_id',
            'value'=>'$data->user->username',
            'visible'=>checkAccess('admin'),
    );
}

// address column
$columns[] =        array(
        'name'=>'address_id',

        'value'=>'$data->address',
);

// statistic column
$columns[] =        array(
        'name'=>'flatCount',
        'value'=>'$data->flatCount',
        'cssClassExpression'=>'numberColumn',
        'htmlOptions'=>array('style'=>'width: 20px;')
);

// operations
$columns[] =       array(
        'class'=>'bootstrap.widgets.BootButtonColumn',
        'template' => '{view} {update} {delete}',
        'buttons' => array(
                'view' => array(
                        'visible'=>'checkAccess("Block.View")',
                        'label'=> 'Nézet',
                        'options'=>array(
                                'class'=>'btn btn- view'
                        )
                ),
                'update' => array(
                        'visible'=>'checkAccess("Block.Update")',
                        'label'=> 'Szerkeszt',
                        'options'=>array(
                                'class'=>'btn btn- btn-info'
                        )
                ),
                'delete' => array(
                        'visible'=>'checkAccess("Block.Delete")',
                        'label'=> 'Töröl',
                        'options'=>array(
                                'class'=>'btn btn- btn-inverse'
                        )
                )
        ),
        'htmlOptions'=>array('style'=>'width: 150px'),
);

$this->beginWidget('application.components.widgets.Box',
        array('title'=>'!building Háztömbök',
                'search'=> array($model, 'filter'),
        ));

    $this->widget('bootstrap.widgets.BootGridView', array(
            'id'=>'block-grid',
            'summaryText'=>'',
            'dataProvider'=>$model->search(),
            'columns'=>$columns
    ));

    echo "<hr />";

    if(checkAccess('Block.Create')){
        echo hyperlink('Új háztömb', array('block/create'), array('class'=>'btn-primary'));
    }


$this->endWidget();
